﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLL;
using System.Data;
using System.IO;
using System.Drawing;
public partial class administrator_uc_admin_e_groups : WebPageSecurity
{
    public static bool IsAdmin;
    protected void Page_Load(object sender, EventArgs e)
    {        
        if (!IsPostBack)
        {            
            if (!string.IsNullOrEmpty(Request.QueryString["itemid"]))
            {                
                LoadDataInfo(Request.QueryString["itemid"].ToString().Trim());                
            }
        }
    }    
    private void LoadDataInfo(string ItemID)
    {
        DataTable dt = new BLL.CmsBLL().Groups_ViewItemByID(new Guid(ItemID));
        if (dt.Rows.Count > 0)
        {
            hdItemID.Value = dt.Rows[0]["GroupID"] + "";
            IsAdmin = (bool)dt.Rows[0]["IsAdmin"];
            txtGroupName.Text = dt.Rows[0]["GroupName"].ToString();
            txtDescription.Text = dt.Rows[0]["Description"].ToString();  
        }
        else
            lblMessage.Text = "Load data failt!";
    }    
    protected void lbtEditItem_Click(object sender, EventArgs e)
    {
        try
        {
            new CmsBLL().Groups_UpDateItem(new Guid(hdItemID.Value.ToString()), txtGroupName.Text, txtDescription.Text, IsAdmin);
            lblMessage.Text = "Cập nhật thành công!";            
        }
        catch (Exception ex)
        {
            lblMessage.Text = "ERROR! " + ex.Message.ToString();
        }
    }   
}